Carbon


PBReadSync

Header: Devices.h Carbon status: Modified

Reads any number of bytes from an open file.

OSErr PBReadSync (
    ParmBlkPtr paramBlock
);
Parameter descriptions
paramBlock

A pointer to a basic File Manager parameter block.

function result

A result code.

DISCUSSION

The relevant fields of the parameter block are:

This function attempts to read ioReqCount bytes from the open file whose access path is specified in the ioRefNum field and transfer them to the data buffer pointed to by the ioBuffer field. The position of the mark is specified by ioPosMode and ioPosOffset. If your application tries to read past the logical end-of-file, PBReadSync reads the data, moves the mark to the end-of-file, and returns eofErr as its function result. Otherwise, PBReadSync moves the file mark to the byte following the last byte read and returns noErr.

You can specify that PBRead read the file data 1 byte at a time until the requested number of bytes have been read or until the end-of-file is reached. To do so, set bit 7 of the ioPosMode field. Similarly, you can specify that PBReadSync should stop reading data when it reaches an application-defined newline character. To do so, place the ASCII code of that character into the high-order byte of the ioPosMode field; you must also set bit 7 of that field to enable newline mode.

When reading data in newline mode, PBReadSync returns the newline character as part of the data read and sets ioActCount to the actual number of bytes placed into the buffer (which includes the newline character).

AVAILABILITY

Modified in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.

CARBON NOTES

This function is only supported for reading from open files.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)